package _0_LSP.A0_Rec_Squre;

import org.junit.Test;

public class SmartTest {
    public void resize(Rectangle rec) {
        while (rec.getWidth() <= rec.getHeight()) {
            rec.setWidth(rec.getWidth() + 1);
            System.out.println(rec.getHeight() + " " + rec.getWidth());
        }
    }

    @Test
    public void test() {
        SmartTest one = new SmartTest();
        Rectangle rec = new Rectangle();
        rec.setHeight(100);
        rec.setWidth(99);
        one.resize(rec);

        //里氏代换被破坏，因为子类正方形不再适用父类出现的地方
        Rectangle square = new Square();
        square.setHeight(100);
        square.setWidth(9);
        one.resize(square);
    }
}
